﻿namespace CV.Dal.Mongo.Test.Impl
{
    using CV.Dal.Mongo.Impl;
    using CV.Dal.Mongo.Test.Fakes;
    using CV.Dal.Mongo.Tools;
    using CV.Entities.Dto;
    using CV.Interfaces.Tools;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System;
    using System.Linq;

    [TestClass]
    public class UserAOTest
    {
        private static readonly IConfigurationWrapper configuration = new FakeConfigurationWrapper();

        public static CVMongoClient GetClientInstance()
        {
            return new CVMongoClient(configuration);
        }



        [TestMethod]
        public void TestCreate()
        {
            var ao = new UserAO(GetClientInstance());
            var result = ao.Create(new User()
            {
                DateOfBirth = DateTime.Today,
                FirstName = "FirstName",
                LastName = "LastName",
                Login = "Login",
                Password = "Password"
            });

            Assert.IsNotNull(result);
            Assert.AreNotEqual(Guid.Empty, result.Id);
            Assert.AreNotEqual("Password", result.Password);
        }



        [TestMethod]
        public void TestListAll()
        {
            var ao = new UserAO(GetClientInstance());
            var result = ao.ListAll();

            Assert.AreNotEqual(0, result.Count());
        }
    }
}
